package org.example.design.proxy.staticproxy;

import org.example.design.proxy.UserService;
import org.example.design.proxy.UserServiceImp;

/**
 * @author huangshen
 * @version 0
 * @description UserServiceProxy
 * @since 2022/2/6 21:22
 */
public class UserServiceProxy implements UserService {

    private UserServiceImp userServiceImp;

    public void setUserServiceImp(UserServiceImp userServiceImp) {
        this.userServiceImp = userServiceImp;
    }

    @Override
    public void add() {
        log("add");
        userServiceImp.add();
    }

    @Override
    public void delete() {
        log("delete");
        userServiceImp.delete();
    }

    @Override
    public void update() {
        log("update");
        userServiceImp.update();
    }

    @Override
    public void query() {
        log("query");
        userServiceImp.query();
    }

    private void log(String msg) {
        System.out.println("invoke " + msg + "方法");
    }
}
